package com.whut.service.impl;

import com.whut.mapper.ProblemcollectMapper;
import com.whut.mapper.ZlabelpositionMapper;
import com.whut.model.Zlabelposition;
import com.whut.service.ZLabelPosition;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;


@Service("ZLabelPosition")
public class ZlabelPosition implements ZLabelPosition {

    @Resource
    public ZlabelpositionMapper ZlabelpositionMapper;
    @Resource
    public ProblemcollectMapper ProblemcollectMapper;

    @Override
    public ArrayList getPosition(Integer projectId) {
        ArrayList arr = ZlabelpositionMapper.selectPosition(projectId);
        return arr;
    }

    @Override
    public int setPosition(Zlabelposition position) {
        int res = 123;
        Zlabelposition isExist = position;
        String str = ZlabelpositionMapper.selectPositionByGUID(position.getProjectGUID());
        System.out.println(str);
        if (str == null) {
            ZlabelpositionMapper.insertSelective(position);
        } else {
            ZlabelpositionMapper.updatePosition(position.getPositionX(), position.getPositionY(), position.getPositionZ(), position.getProjectGUID());
        }
        return res;
    }

    @Override
    public ArrayList getProblem(String name) {
        ArrayList problemArr = ProblemcollectMapper.selectProblem(name);
        return problemArr;
    }

    @Override
    public int[] getProblemNum(String projectName, Integer quality, Integer security) {
        int[] arr = new int[2];
        arr[0]= ProblemcollectMapper.selectProblemNum(projectName,quality);
        arr[1]=ProblemcollectMapper.selectProblemNum(projectName,security);
        return arr;
    }


}
